using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for Utility
/// </summary>
public class ExtendFunctional
{
    public static bool IsNumberic(string str)
    {
        try
        {
            if (string.IsNullOrEmpty(str)) return false;
            int i = Convert.ToInt32(str);
            return true;
        }
        catch { return false; }
    }
    

    public static void DeleteImageInFolder(string path)
    {
        if (System.IO.File.Exists(path))
        {
            System.IO.File.Delete(path);
        }
    }
    public static bool IsImageFile(string fileName)
    {
        try
        {
            string[] extend = new string[] { ".gif", ".bmp", ".jpg", ".jpge", ".png" };

            string ex = fileName.Substring(fileName.Length - 4).ToLower();
            foreach (string s in extend)
                if (s == ex) return true;
            return false;
        }
        catch { return false; }
    }
    public static string UploadPicture(string _sFolder, HttpPostedFile _File)
    {
        string _sResult = "";
        if (!System.IO.Directory.Exists(_sFolder))
            System.IO.Directory.CreateDirectory(_sFolder);

        string _sFileName = System.IO.Path.GetFileName(_File.FileName);
        try
        {
            _File.SaveAs(_sFolder + "/" + _sFileName);
            _sResult = _sFileName;
        }
        catch (Exception)
        {

        }
        return _sResult;
    }
}
